using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Configuration;

namespace eShop.Business
{
    public class CustomSiteMap
    {
        #region Direct Link Access Properties

        /* *******************************************
         * There needs to be a property for each page,
         * it is strongly recommanded to navigate pages
         * this way and there should not be any hard
         * coded url in the whole application.
         * *******************************************/

        public static string Home
        {
            get { return GetUrl(PageTitle.Home); }
        }

        public static string Register
        {
            get { return GetUrl(PageTitle.Register); }
        }

        public static string Login
        {
            get { return GetUrl(PageTitle.Login); }
        }

        public static string Recover
        {
            get { return GetUrl(PageTitle.Recover); }
        }


        public static string RegistrationSuccessful
        {
            get { return GetUrl(PageTitle.Registration_Successful); }
        }

        public static string Shipping
        {
            get { return GetUrl(PageTitle.Shipping); }
        }

        public static string Manufacturer
        {
            get { return GetUrl(PageTitle.Manufacturer); }
        }

        public static string Articles
        {
            get { return GetUrl(PageTitle.Articles); }
        }

        public static string ArticleDetails
        {
            get { return GetUrl(PageTitle.Article_Details); }
        }

        public static string Catalog
        {
            get { return GetUrl(PageTitle.Catalog); }
        }

        public static string UserHome
        {
            get { return GetUrl(PageTitle.User_Home); }
        }

        public static string OrderStatus
        {
            get { return GetUrl(PageTitle.Order_Status); }
        }

        public static string ShoppingList
        {
            get { return GetUrl(PageTitle.Shopping_List); }
        }

        public static string EditProfile
        {
            get { return GetUrl(PageTitle.Edit_Profile); }
        }

        public static string ChangePassword
        {
            get { return GetUrl(PageTitle.Change_Password); }
        }

        public static string AdminHome
        {
            get { return GetUrl(PageTitle.Admin_Home); }
        }
        public static string AdminLogin
        {
            get { return GetUrl(PageTitle.Admin_login); }
        }

        public static string SiteConfiguration
        {
            get { return GetUrl(PageTitle.Site_Configuration); }
        }

        public static string AboutUs
        {
            get { return GetUrl(PageTitle.About_Us); }
        }

        public static string ContactUs
        {
            get { return GetUrl(PageTitle.Contact_Us); }
        }

        public static string ShoppingCart
        {
            get { return GetUrl(PageTitle.Shopping_Cart); }
        }

        public static string PrivacyPolicy
        {
            get { return GetUrl(PageTitle.Privacy_Policy); }
        }

        public static string NewsEvents
        {
            get { return GetUrl(PageTitle.News_Events); }
        }


        public static string Products
        {
            get { return GetUrl(PageTitle.Products); }
        }

        public static string ProductsSearched
        {
            get { return GetUrl(PageTitle.Products_Searched); }
        }

        public static string ReturnPolicy
        {
            get { return GetUrl(PageTitle.Return_Policy); }
        }

        public static string ShippingPolicy
        {
            get { return GetUrl(PageTitle.Shipping_Policy); }
        }

        public static string Sitemap
        {
            get { return GetUrl(PageTitle.Sitemap); }
        }

        public static string CategoryAdd
        {
            get { return GetUrl(PageTitle.Category_Add); }
        }

        public static string CategoryList
        {
            get { return GetUrl(PageTitle.Category_List); }
        }

        public static string CategoryEdit
        {
            get { return GetUrl(PageTitle.Category_Edit); }
        }

        public static string ManufacturerAdd
        {
            get { return GetUrl(PageTitle.Manufacturer_Add); }
        }

        public static string ManufacturerList
        {
            get { return GetUrl(PageTitle.Manufacturer_List); }
        }

        public static string ManufacturerEdit
        {
            get { return GetUrl(PageTitle.Manufacturer_Edit); }
        }

        public static string TermsAndConditions
        {
            get { return GetUrl(PageTitle.Terms_and_Conditions); }
        }
        public static string PreCheckout
        {
            get { return GetUrl(PageTitle.Pre_Checkout); }
        }
        public static string OrderSummary
        {
            get { return GetUrl(PageTitle.Order_Summary); }
        }

        public static string Receipt
        {
            get { return GetUrl(PageTitle.Receipt); }
        }

        public static string ProductList
        {
            get { return GetUrl(PageTitle.Product_List); }
        }

        public static string ProductAdd
        {
            get { return GetUrl(PageTitle.Product_Add); }
        }

        public static string ProductEdit
        {
            get { return GetUrl(PageTitle.Product_Edit); }
        }

        public static string ShippingEdit
        {
            get { return GetUrl(PageTitle.Shipping_Edit); }
        }


        public static string AboutUsEdit
        {
            get { return GetUrl(PageTitle.About_Us_Edit); }
        }
        public static string PrivacyPolicyEdit
        {
            get { return GetUrl(PageTitle.Privacy_Policy_Edit); }
        }

        public static string ReturnPolicyEdit
        {
            get { return GetUrl(PageTitle.Return_Policy_Edit); }
        }

        public static string ShippingPolicyEdit
        {
            get { return GetUrl(PageTitle.Shipping_Policy_Edit); }
        }

        public static string ContactUsEdit
        {
            get { return GetUrl(PageTitle.Contact_Us_Edit); }
        }

        public static string ArticlesList
        {
            get { return GetUrl(PageTitle.Articles_List); }
        }
        public static string ArticlesAdd
        {
            get { return GetUrl(PageTitle.Articles_Add); }
        }
        public static string ArticlesEdit
        {
            get { return GetUrl(PageTitle.Articles_Edit); }
        }

        public static string NewsList
        {
            get { return GetUrl(PageTitle.News_List); }
        }
        public static string NewsAdd
        {
            get { return GetUrl(PageTitle.News_Add); }
        }
        public static string NewsEdit
        {
            get { return GetUrl(PageTitle.News_Edit); }
        }
        public static string EventsList
        {
            get { return GetUrl(PageTitle.Events_List); }
        }
        public static string EventsAdd
        {
            get { return GetUrl(PageTitle.Events_Add); }
        }
        public static string EventsEdit
        {
            get { return GetUrl(PageTitle.Events_Edit); }
        }
        public static string NewsDetails
        {
            get { return GetUrl(PageTitle.News_Details); }
        }
        public static string EventsDetails
        {
            get { return GetUrl(PageTitle.Events_Details); }
        }

        public static string StateTaxList
        {
            get { return GetUrl(PageTitle.State_Tax_List); }
        }

        public static string StateTaxEdit
        {
            get { return GetUrl(PageTitle.State_Tax_Edit); }
        }

        public static string StateTaxAdd
        {
            get { return GetUrl(PageTitle.State_Tax_Add); }
        }
        public static string TaxList
        {
            get { return GetUrl(PageTitle.Tax_List); }
        }

        public static string TaxEdit
        {
            get { return GetUrl(PageTitle.Tax_Edit); }
        }

        public static string TaxAdd
        {
            get { return GetUrl(PageTitle.Tax_Add); }
        }
        public static string ShipmentCostList
        {
            get { return GetUrl(PageTitle.Shipment_Cost_List); }
        }
        public static string ShipmentCostAdd
        {
            get { return GetUrl(PageTitle.Shipment_Cost_Add); }
        }
        public static string ShipmentCostEdit
        {
            get { return GetUrl(PageTitle.Shipment_Cost_Edit); }
        }
        public static string CustomerList
        {
            get { return GetUrl(PageTitle.Customer_List); }
        }
        public static string CustomerAdd
        {
            get { return GetUrl(PageTitle.Customer_Add); }
        }
        public static string CustomerEdit
        {
            get { return GetUrl(PageTitle.Customer_Edit); }
        }
        public static string Settings
        {
            get { return GetUrl(PageTitle.Settings); }
        }

        public static string CouponList
        {
            get { return GetUrl(PageTitle.Coupon_List); }
        }

        public static string CouponEdit
        {
            get { return GetUrl(PageTitle.Coupon_Edit); }
        }

        public static string CouponAdd
        {
            get { return GetUrl(PageTitle.Coupon_Add); }
        }

        public static string SalesCCSuccess
        {
            get { return GetUrl(PageTitle.Sales_CC_Success); }
        }

        public static string SalesCCFail
        {
            get { return GetUrl(PageTitle.Sales_CC_Fail); }
        }

        public static string NoStockRequest
        {
            get { return GetUrl(PageTitle.No_Stock_Request); }
        }

        public static string TermsAndConditionsEdit
        {
            get { return GetUrl(PageTitle.Terms_and_Conditions_Edit); }
        }

        public static string CustomerService
        {
            get { return GetUrl(PageTitle.Customer_Service); }
        }

        public static string OurGuarantee
        {
            get { return GetUrl(PageTitle.Our_Guarantee); }
        }

        public static string FAQ
        {
            get { return GetUrl(PageTitle.FAQ); }
        }
      
        public static string MyAccount
        {
            get { return GetUrl(PageTitle.My_Account); }
        }

        public static string GiftCertificates
        {
            get { return GetUrl(PageTitle.Gift_Certificates); }
        }

        public static string Newsletter
        {
            get { return GetUrl(PageTitle.Newsletter); }
        }

        public static string YourFeedback
        {
            get { return GetUrl(PageTitle.Your_Feedback); }
        }
      public static string WebsiteProblems
            {
                get { return GetUrl(PageTitle.Website_Problems); }
            }

      public static string CustomerServiceEdit
      {
          get { return GetUrl(PageTitle.Customer_Service_Edit); }
      }
      public static string ExportImport
      {
          get { return GetUrl(PageTitle.Export_Import); }
      }
      public static string Subscribers
      {
          get { return GetUrl(PageTitle.Subscribers); }
      }

      public static string SubscriberGroups
      {
          get { return GetUrl(PageTitle.Subscriber_Groups); }
      }

      public static string SendNewsletter
      {
          get { return GetUrl(PageTitle.Send_Newsletter); }
      }

      public static string NewsletterArchive
      {
          get { return GetUrl(PageTitle.Newsletter_Archive); }
      }
      public static string AddSubscriber 
      {
          get { return GetUrl(PageTitle.Add_Subscriber); }
      }
      public static string AddSubscriberGroup
      {
          get { return GetUrl(PageTitle.Add_Subscriber_Group); }
      }
      public static string NewsletterPrint
      {
          get { return GetUrl(PageTitle.Newsletter_Print); }
      }
      public static string CCCode
      {
          get { return GetUrl(PageTitle.CC_Code); }
      }
      public static string InvoicePrintPage
      {
          get { return GetUrl(PageTitle.Invoice_Print_Page); }
      }
      public static string FreeShipping
      {
          get { return GetUrl(PageTitle.Free_Shipping); }
      }
      public static string UnconditionalGuarantee
      {
          get { return GetUrl(PageTitle.Unconditional_Guarantee); }
      }
      public static string Recipies
      {
          get { return GetUrl(PageTitle.Recipies); }
      }
      public static string eCatalog
      {
          get { return GetUrl(PageTitle.eCatalog); }
      }
      public static string GiftIdeas
      {
          get { return GetUrl(PageTitle.gift_ideas); }
      }
      public static string WebsiteSpecials
      {
          get { return GetUrl(PageTitle.website_specials); }
      }
      public static string CustomersSatisfaction 
      {
          get { return GetUrl(PageTitle.customers_satisfaction); }
      }
      public static string ProductReviewListing
      {
          get { return GetUrl(PageTitle.ProductReviews_List); }
      }
      public static string GiftInvoicePrintPage 
      {
          get { return GetUrl(PageTitle.Gift_Invoice_Print_Page); }
      }
      public static string MultiGiftInvoicePrintPage
      {
          get { return GetUrl(PageTitle.Multiple_Gift_Invoice_Print_Page); }
      }
      public static string HomePageImageSettings
      {
          get { return GetUrl(PageTitle.Home_Page_Image); }

      }

      public static string MultipleShipReceipt
      {
          get { return GetUrl(PageTitle.Multiple_Ship_Receipt); }

      }

      public static string InvoiceMultipleShip
      {
          get { return GetUrl(PageTitle.Multiple_Invoice_Print_Page); }

      }

        #endregion

        /// <summary>
        /// Takes a page title enumeration and returns 
        /// the url for the page that has the title in
        /// the sitemap file. PageTitle needs to be
        /// unique and there is a scope of perfomance
        /// tune for this method.
        /// </summary>
        /// <param name="pageTitle">Enumeration that represents title in the web.sitemap</param>
        /// <returns>The first url that has the title of the enumeration</returns>
        public static string GetUrl(PageTitle pageTitle)
        {
            SiteMapNodeCollection siteMapNodes = SiteMap.Provider.RootNode.GetAllNodes();

            if (siteMapNodes != null)
            {
                if (SiteMap.Provider.RootNode.Title == pageTitle.ToString())
                    return SiteMap.Provider.RootNode.Url;

                foreach (SiteMapNode node in siteMapNodes)
                {
                    if (node.Title == pageTitle.ToString())
                        return node.Url;
                }
            }

            return null;
        }

        /// <summary>
        /// Unique enumeration for the page titles in the 
        /// web.sitemap file. It is recommanded not to put
        /// same title for multiple url
        /// </summary>
        public enum PageTitle
        {
            Home = 1,
            Register = 2,
            Login = 3,
            Shipping = 4,
            Manufacturer = 5,
            Articles = 6,
            Catalog = 7,
            User_Home = 8,
            Order_Status = 9,
            Shopping_List = 10,
            Edit_Profile = 11,
            Change_Password = 12,
            Admin_Home = 13,
            Site_Configuration = 14,
            About_Us = 15,
            Contact_Us = 16,
            Shopping_Cart = 17,
            Privacy_Policy = 18,
            News_Events = 19,
            Products = 20,
            Return_Policy = 21,
            Shipping_Policy = 22,
            Sitemap = 23,
            Article_Details = 24,
            Category_Add = 25,
            Manufacturer_Add = 26,
            Manufacturer_List = 27,
            Manufacturer_Edit = 28,
            Registration_Successful = 29,
            Recover = 30,
            Admin_login = 31,
            Category_List = 32,
            Category_Edit = 33,
            Terms_and_Conditions = 34,
            Pre_Checkout = 35,
            Order_Summary = 36,
            Receipt = 37,
            Product_List = 38,
            Product_Add = 39,
            Product_Edit = 40,
            Shipping_Edit = 41,
            About_Us_Edit = 42,
            Privacy_Policy_Edit = 43,
            Return_Policy_Edit = 44,
            Shipping_Policy_Edit = 45,
            Contact_Us_Edit = 46,
            Articles_List = 47,
            Articles_Add = 48,
            Articles_Edit = 49,
            News_List = 50,
            News_Add = 51,
            News_Edit = 52,
            Events_List = 53,
            Events_Add = 54,
            Events_Edit = 55,
            News_Details = 56,
            Events_Details = 57,
            State_Tax_List = 58,
            State_Tax_Add = 59,
            State_Tax_Edit = 60,
            Shipment_Cost_List = 61,
            Shipment_Cost_Add = 62,
            Shipment_Cost_Edit = 63,
            Customer_List = 64,
            Customer_Add = 65,
            Customer_Edit = 66,
            Settings = 67,
            Coupon_List = 68,
            Coupon_Add = 69,
            Coupon_Edit = 70,
            Sales_CC_Success = 71,
            Sales_CC_Fail = 72,
            No_Stock_Request = 73,
            Terms_and_Conditions_Edit = 74,
            Customer_Service=75,
            Our_Guarantee=76,
            FAQ=77,
            My_Account=78,
            customers_satisfaction = 79,
            Gift_Certificates=80,
            eCatalog = 81,
            Newsletter=82,
            Your_Feedback=83,
            Website_Problems= 84,
            gift_ideas = 85,
            website_specials = 86,
            Export_Import = 87,
            Subscribers = 79,
            Subscriber_Groups = 88,
            Send_Newsletter = 89,
            Newsletter_Archive = 90,
            Customer_Service_Edit = 91,
            Add_Subscriber=92,
            Add_Subscriber_Group=93,
            Newsletter_Print=94,
            Invoice_Print_Page=95,
            Free_Shipping=96,
            Unconditional_Guarantee=97,
            Recipies=98,
            ProductReviews_List=99,
            Gift_Invoice_Print_Page=100,
            CC_Code = 101,
            Home_Page_Image=102,
            Multiple_Invoice_Print_Page = 103,
            Multiple_Ship_Receipt = 104,
            Multiple_Gift_Invoice_Print_Page = 105,
            Tax_List = 106,
            Tax_Add = 107,
            Tax_Edit = 108,
            Products_Searched = 109
        }
    }
}
